﻿#pragma once

#include <QDialog>
#include "ui_YPlayVideoPreviewWindow.h"

#include "player_controller/PlayerController.h"

class YPlayVideoPreviewWindow : public QDialog
{
	Q_OBJECT

public:
	YPlayVideoPreviewWindow(QWidget *parent = nullptr);
	~YPlayVideoPreviewWindow();

	/// <summary>
	/// 打开Url并播放
	/// </summary>
	/// <param name="url">用于视频播放的url</param>
	/// <returns></returns>
	bool Open(const char* url);

	/// <summary>
	/// 定时器（Qt自带的）
	/// </summary>
	/// <param name="ev"></param>
	void timerEvent(QTimerEvent* ev) override;

	/// <summary>
	/// 关闭QDialog并清空资源
	/// </summary>
	void Close();

	/// <summary>
	/// 当窗口关闭时的回调函数（Qt自带的）
	/// </summary>
	/// <param name="ev"></param>
	void closeEvent(QCloseEvent* ev) override;


public slots:
	void SetSpeed();    //控制播放速度
	void PlayPos();     //控制播放进度 进度条松开
	void Pause();       //播放和暂停
	void Move();        //进度条拖动


private:
	Ui::YPlayVideoPreviewWindow ui;

	PlayerController player;

	int timerId = 0;
};
